// function toggle(e) {
//   console.log('callback ran');
//   e.target.classList.toggle('danger');
// }

// document.querySelector('button').addEventListener('click', toggle);
const posts = [
    { title: "帖⼦⼀", body: "这是帖⼦⼀" },
    { title: "帖⼦⼆", body: "这是帖⼦⼆" }
  ];
  function getPosts() {
    setTimeout(() => {
      posts.forEach((post) => {
        const div = document.createElement("div");
        div.innerHTML = `<h3>${post.title}</h3><p>${post.body}</p>`;
        document.querySelector("#posts").appendChild(div);
      });
    }, 1000);
  }
  getPosts();
  function createPost(post, cb) {
    setTimeout(() => {
      posts.push(post);
      cb();
    }, 2000);
  }
  createPost({ title: "帖⼦三", body: "这是帖⼦三" }, getPosts);